

#include "UserAgent.h"

UserAgent *UserAgent::_pInstance = nullptr;

UserAgent *UserAgent::Instance() {
  if (_pInstance == nullptr) {
    _pInstance = new UserAgent();
  }

  return _pInstance;
}

void UserAgent::Destroy() {
  DELETE_PTR(_pInstance)
}

UserAgent::UserAgent() {
  _pDeviceManager = new DeviceManager();
}

UserAgent::~UserAgent() {
  DELETE_PTR(_pDeviceManager)
}

void UserAgent::setCodecType(bool softDecode, bool softEncode) {
  _SoftDecode = softDecode;
  _SoftEncode = softEncode;
}

bool UserAgent::addScreenDevice(int32_t width, int32_t height) {
  return true;
}

bool UserAgent::addIPCameraDevice(const char *stStreamUrl, bool softDecode, int32_t devType) {
  if (_pDeviceManager) {
    return _pDeviceManager->addIPCameraDevice(stStreamUrl, softDecode,
                                              static_cast<DeviceType>(devType));
  }

  return false;
}

void UserAgent::deleteCaptureDevice(int32_t devID) {
  if (_pDeviceManager) {
    _pDeviceManager->deleteDevice(devID);
  }
}

void UserAgent::clearCaptureDevice() {
  if (_pDeviceManager) {
    _pDeviceManager->clearDevice();
  }
}

void UserAgent::modifyCameraDevice(int32_t width, int32_t height) {
  if (_pDeviceManager) {
    _pDeviceManager->modifyCameraDevice(width, height);
  }
}

void UserAgent::modifyCameraDevice(int32_t devID, int32_t width, int32_t height) {
  if (_pDeviceManager) {
    _pDeviceManager->modifyCameraDevice(devID, width, height);
  }
}

void UserAgent::modifyAudioDevice(int32_t sampleRate, int32_t channelNum, int32_t samplesBitPer) {
  if (_pDeviceManager) {
    _pDeviceManager->modifyAudioDevice(sampleRate, channelNum, samplesBitPer);
  }
}

IDevice *UserAgent::findCaptureDevice(int32_t devID) {
  if (_pDeviceManager) {
    _pDeviceManager->findDeviceByID(devID);
  }
}

std::list<IDevice *> UserAgent::getCaptureDevice() {
  return _pDeviceManager->getDeviceList();
}

int32_t UserAgent::getCameraDeviceNum() {
  if (_pDeviceManager) {
    _pDeviceManager->getCameraDeviceNum();
  }
}